#!/usr/bin/env python3
# -*- coding: utf-8 -*-

import requests
import json

def check_documents():
    """检查知识库中的文档"""
    try:
        response = requests.get('http://localhost:8080/knowledge_base/documents')
        
        if response.status_code == 200:
            result = response.json()
            print("✅ 获取文档列表成功")
            print(f"状态码: {result.get('code')}")
            print(f"消息: {result.get('msg')}")
            
            documents = result.get('data', [])
            print(f"\n📚 文档列表 (共 {len(documents)} 个):")
            
            for i, doc in enumerate(documents, 1):
                print(f"\n{i}. 文档ID: {doc.get('file_id')}")
                print(f"   标题: {doc.get('title')}")
                print(f"   权限设置: {doc.get('permission_set')}")
                
                # 检查是否是我们刚保存的预案
                if 'emergency_plan' in doc.get('file_id', ''):
                    print(f"   🎯 这是刚保存的应急预案!")
                    
        else:
            print(f"❌ 获取文档列表失败，状态码: {response.status_code}")
            print(f"响应: {response.text}")
            
    except Exception as e:
        print(f"❌ 请求异常: {e}")

if __name__ == "__main__":
    check_documents() 